package com.example.administrator.nurse.model.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.administrator.nurse.R;

import java.util.ArrayList;

/**
 * Created by Administrator on 2016/3/30.
 */
public class GridAdapter extends BaseAdapter {
    ArrayList<String > titleList;
    int layoutId;
    Context context;
    public GridAdapter(ArrayList<String > titleList,int layoutId,Context context){
        this.titleList=titleList;
        this.layoutId=layoutId;
        this.context=context;
    }
    @Override
    public int getCount() {
        return titleList.size();
    }

    @Override
    public Object getItem(int position) {
        return titleList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if(convertView==null){
            convertView=View.inflate(context,layoutId,null);
        }
        TextView textView= (TextView) ViewHolder.get(R.id.main_item,convertView);
        textView.setText(titleList.get(position));
        return convertView;
    }
}
